// pages/wdgz/wdgz.js
var app = getApp();
var api = require('../../utils/interface.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    tup: [
      // { images: "/images/duola2.png", names: "韩瑶", guanzhu: "1", is_share: false, article_id: 0 },
      // { images: "/images/duola2.png", names: "赵志远", guanzhu: "2", is_share: false, article_id: 1 },
      // { images: "/images/duola2.png", names: "哆啦", guanzhu: "1", is_share: true, article_id: 2 },
    ],
    page: 1,
    size: 10,
    isload: false,
    pkid: 0,
  },
  changeColor: function(e) {
    var that = this;
    app.Post(api.wxapp.follow_delete, {
      accountId: e.currentTarget.dataset.id
    }, function(res) {
      if (res.code == 1) {
        app.ShowMsg("取消成功");
        that.setData({
          page: 1,
          tup: []
        });
        that.get_focus_list();
      } else {
        app.WxAlert(res.msg);
      }
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.setData({
      pkid: options.id,
      isOwn: options.own == undefined ? true : false
    });
    this.get_focus_list();
  },
  //查询我关注
  get_focus_list: function() {
    var that = this;
    app.Post(api.wxapp.get_follow_focus_list, {
      accountId: that.data.pkid,
      page: that.data.page,
      size: that.data.size
    }, function(res) {
      if (res.code == 1) {

        that.setData({
          tup: that.data.tup.concat(res.data.FansList)
        });
        if (res.data.FansList.length < that.data.size) {
          that.setData({
            isload: true
          });
        } else {
          that.setData({
            page: that.data.page + 1
          });
        }
      } else {
        app.WxAlert(res.msg);
      }
    });
  },
  bindgrzy: function (e) {
    wx.navigateTo({
      url: '../grzy/grzy?id=' + e.currentTarget.dataset.id,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    this.get__focus_list();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})